package com.template.web.security;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import net.tanesha.recaptcha.ReCaptcha;
import net.tanesha.recaptcha.ReCaptchaFactory;
import net.tanesha.recaptcha.ReCaptchaResponse;

import org.hibernate.validator.constraints.Email;
import org.springframework.roo.addon.javabean.RooJavaBean;

/**
 * @author rohit
 *
 */
@RooJavaBean
public class SignUpForm {

	@NotNull
	@Size(min = 1, max = 100)
	private String firstName;

	@NotNull
	@Size(min = 1, max = 100)
	private String lastName;

	@NotNull
	@Size(min = 1, max = 100)
	@Email
	private String emailAddress;

	@NotNull
	@Size(min = 5, max = 100)
	private String password;

	private String retypePassword;

//	private String recaptchaChallenge;
//	private String recaptchaResponse;
//
//	private ReCaptcha reCatcpha;
//	private String reCaptchaErrorMessage;


	public SignUpForm() {
//		reCatcpha = ReCaptchaFactory.newReCaptcha(
//				"6LdfmL8SAAAAAFnT0l3UNPOV8mkpHIown-ysSR1g",
//				"6LdfmL8SAAAAAHKPqUQV5SxrRX9Id6a8cQo-mgpE", false);
	}


//	public void setRecaptcha_challenge_field(String recaptchaChallenge) {
//		this.recaptchaChallenge = recaptchaChallenge;
//	}
//
//	public void setRecaptcha_response_field(String recaptchaResponse) {
//		this.recaptchaResponse = recaptchaResponse;
//	}
//
//	public String getReCaptchaHtml() {
//		return reCatcpha.createRecaptchaHtml(reCaptchaErrorMessage, null);
//	}
//
//	@AssertTrue(message = "Wrong captcha")
//	public boolean isValidCaptcha() {
//		ReCaptchaResponse reCaptchaResponse = reCatcpha.checkAnswer(
//				"localhost", getRecaptchaChallenge(), getRecaptchaResponse());
//		boolean result = reCaptchaResponse.isValid();
//
//		if (!result) {
//			reCaptchaErrorMessage = "Wrong captcha answer";
//		}
//
//		return result;
//	}

}
